package com.hksj.em.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hksj.common.core.model.Rest;
import com.hksj.em.query.AlarmInfoQuery;
import com.hksj.em.service.AlarmInfoService;
import com.hksj.em.vo.AlarmPropertyVO;
import com.hksj.em.vo.AlarmRankCountVO;
import com.hksj.em.vo.AlarmRecordVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Api(tags = "智慧手术室-告警信息")
@RestController
@RequestMapping("/api/alarmInfo")
public class AlarmInfoController {

    @Autowired
    private AlarmInfoService alarmInfoService;

    @ApiOperation(value = "根据专业编码查询设备数量")
    @PostMapping("/queryAlarmRecord")
    public Rest<IPage<AlarmRecordVO>> queryAlarmRecord(@RequestBody AlarmInfoQuery query) {
        IPage<AlarmRecordVO> pageList = alarmInfoService.queryAlarmRecord(query);
        return Rest.ok(pageList);
    }

    @ApiOperation(value = "报警区域排名前十")
    @PostMapping("/queryAlarmRankingList")
    public Rest<List<AlarmRankCountVO>> queryAlarmRankingList(@RequestBody AlarmInfoQuery query) {
        List<AlarmRankCountVO> list = alarmInfoService.queryAlarmRankingList(query);
        return Rest.ok(list);
    }

    @ApiOperation(value = "报警类型分布")
    @PostMapping("/queryAlarmByProperty")
    public Rest<List<AlarmPropertyVO>> queryAlarmByProperty(@RequestBody AlarmInfoQuery query) {
        List<AlarmPropertyVO> list = alarmInfoService.queryAlarmByProperty(query);
        return Rest.ok(list);
    }

    @ApiOperation(value = "报警记录导出")
    @PostMapping("/exportAlarmExcelData")
    public void exportAlarmExcelData(@RequestBody AlarmInfoQuery query, HttpServletResponse response) {
        alarmInfoService.exportAlarmExcelData(query, response);
    }
}
